package com.example.homework9.service;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

import com.example.homework9.MusicHelper;

public class MusicService2 extends Service {
    private MusicHelper musicHelper = null;

    @Override
    public void onCreate() {
        Log.d("MusicService-----------","onCreate");
        super.onCreate();
        musicHelper = new MusicHelper(this);
    }

    @Override
    public void onDestroy() {
        Log.d("MusicService-----------","onDestroy");
        super.onDestroy();
    }

    public class MyBinder extends Binder {
        private MusicService2 service2;
        public MyBinder(MusicService2 service2) {
            this.service2 = service2;
        }

        public void play() {
            service2.musicHelper.play();
        }

        public void next() {
            service2.musicHelper.next();
        }

        public void pause() {
            service2.musicHelper.pause();
        }

        public void destroy() {
            service2.musicHelper.destroy();
        }
    }

    @Override
    public IBinder onBind(Intent intent) {
        Log.d("MusicService2--------","onBind");
        return new MyBinder(this);
    }
}